#include<iostream>
using namespace std;
#define ok 0
#define error -1
class SeqList {
private:
	int* list;
	int maxsize;
	int size;
public:
	SeqList();
	~SeqList();
	int list_size();
	void list_insert(int i, int n, int item[]);
	void list_del(int i, int n);
	void list_display();
};
SeqList::SeqList() {
	maxsize = 1000;
	size = 0;
	list = new int[maxsize];
}
SeqList::~SeqList() {
	delete[]list;
}
int SeqList::list_size() {
	return size;
}
void SeqList::list_insert(int i, int n, int item[]) {
	for (int j = size + n - 1; j >= i; j--) {
		if (j - n >= 0) {
			list[j] = list[j - n];
		}
		else {
			break;
		}
	}
	for (int j = 0; j < n; j++) {
		list[i + j - 1] = item[j];
	}
	size += n;
}
void SeqList::list_del(int i, int n) {
	for (int j = i - 1; j < size + n - 2; j++) {
		list[j] = list[j + n];
	}
	size -= n;
}
void SeqList::list_display() {
	cout << size << ' ';
	for (int i = 0; i < size; i++) {
		cout << list[i] << ' ';
	}
	cout << endl;
}
int main()
{
	SeqList sl;
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sl.list_insert(1, n, a);
	sl.list_display();
	int i;
	cin >> i;
	cin >> n;
	int* b = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	sl.list_insert(i, n, b);
	sl.list_display();
	cin >> i;
	cin >> n;
	sl.list_del(i, n);
	sl.list_display();
}